/**
 * v-hasPermi 操作权限处理
 * Copyright (c) 2019 ruoyi
 */

export default {
  mounted(el, binding, vnode) {
    const { value } = binding;
    const permissionsData = window.BTN_AUTH || [];
    if (value && value instanceof Array && value?.length > 0) {
      const permissions = value;
      const hasPermission = permissionsData.some((role) => {
        return permissions.includes(role);
      });
      if (!hasPermission) {
        el.parentNode && el.parentNode.removeChild(el);
      }
    }
  },
};
